package ua.lviv.franko.solvers.stressanalysis.twoDimention.fem.enriched;

import static org.junit.Assert.assertNotNull;

import java.util.List;
import java.util.Scanner;

import org.junit.Before;
import org.junit.Test;
import org.jzy3d.maths.Range;
import org.jzy3d.plot3d.builder.Mapper;

import ua.lviv.franko.integration.ConstantFunction2D;
import ua.lviv.franko.integration.IFunction2D;
import ua.lviv.franko.mlsFunctions.oneDimension.weightFunctions.CubicSpline;
import ua.lviv.franko.mlsFunctions.twoDimension.Particle;
import ua.lviv.franko.mlsFunctions.twoDimension.weightFunctions.SquareSupport;
import ua.lviv.franko.triangulation.SaveStructures.Node;
import ua.lviv.franko.visualisation.Visualise3D;

public class BilinearIsoparamerticEnrichedQuadrilateralTest {
	private BilinearIsoparamerticEnrichedQuadrilateral	element;
	private double										k1			= 1;
	private double										k2			= 0.5;
	private double										k3			= 0.25;

	private IFunction2D									f1Function	= new ConstantFunction2D(10);
	private IFunction2D									f2Function	= new ConstantFunction2D(10);
	private Node										A			= new Node(-1.0, -1.0, true, 0);
	private Node										B			= new Node(1.0, -1.0, true, 1);
	private Node										C			= new Node(1.0, 1.0, true, 0);
	private Node										D			= new Node(-1.0, 1.0, true, 0);

	private List<Particle>								particles;

	@Before
	public void setUp() throws Exception {
		// particles =
		// BilinearIsoparamerticEnrichedQuadrilateral.generateParticlesOnlyInsideQuadElement(5,
		// 5, 2.5);
		particles = BilinearIsoparamerticEnrichedQuadrilateral.generateParticlesInsideQuadElementWithBounderies(5, 5, 3.1);
		element = new BilinearIsoparamerticEnrichedQuadrilateral(k1, k2, k3, f1Function, f2Function, A, B, C, D, particles, 2, new SquareSupport(new CubicSpline()));
		Visualise3D.show(new Mapper() {

			@Override
			public double f(double x, double y) {
				return element.baseMLSFunctions.get(20).calculate(x, y);
			}
		}, new Range(-1.0, 1.0), new Range(-1.0, 1.0));
		new Scanner(System.in).next();
	}

	@Test
	public void testGenerateEnrichmentMatrixVector() {
		element.generateEnrichmentMatrixVector(0);
		assertNotNull(element);
		assertNotNull(element.particles);

	}

}
